{{extend "layout.html"}}

{{block head}}
<style>
#dataform .n-invalid {border: 1px solid #f00;}
</style>
{{end}}
{{block sub_menu}}
{{sub_menu('osadmin','user')}}
{{end}}

{{block content_main}}

<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>
		
		<ul class="breadcrumb">
			<li>
				<i class="icon-home home-icon"></i>
				<a href="/">首页</a>
			</li>
			<li>
				<a href="/user/user">用户管理</a>
			</li>
			<li class="active">修改密码</li>
		</ul><!-- .breadcrumb -->
		
	</div>

	<div class="page-content">
		
		<div class="row">
			<div class="col-xs-12">
				<!-- PAGE CONTENT BEGINS -->
				<div class="alert alert-info">
					<i class="icon-key bigger-150"><sub class="icon-pencil"></sub></i>
					<strong>
						修改密码
					</strong>
				</div>

                <div id="showmsg" class="alert alert-block alert-success" style="display:none">

                </div>

				<form id="dataform" class="form-horizontal">
                    <input type="hidden" name="id" value="{{=id}}"/>
					{{ if not request.user.is_superuser:}}
					<div class="form-group">
						<label class="col-sm-3 control-label no-padding-right" for="oldpassword">
                            <strong> 原始密码 </strong>
                        </label>

						<div class="col-sm-9">
							<input type="password" id="oldpassword" name="oldpassword" placeholder="原始密码"
                                   data-rule="密码: required;remote[/userpost/checkpassword?id={{=id}}]"
                                   class="col-xs-10 col-sm-5" />
						</div>
					</div>
					{{pass}}

					<div class="form-group">
						<label class="col-sm-3 control-label no-padding-right" for="password">
                            <strong> 密码 </strong>
                        </label>

						<div class="col-sm-9">
							<input type="password" id="password" name="password" placeholder="登录密码" data-rule="密码: required;" class="col-xs-10 col-sm-5" />
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label no-padding-right" for="password2">
                            <strong> 密码确认 </strong>
                        </label>

						<div class="col-sm-9">
							<input type="password" id="password2" placeholder="再次输入登录密码" data-rule="确认密码: required;match(password);" class="col-xs-10 col-sm-5" />
						</div>
					</div>

					<div class="clearfix form-actions">
						<div class="col-md-offset-3 col-md-9">
							<button class="btn btn-primary" type="submit">
								<i class="icon-save bigger-110"></i>
								保存
							</button>

							&nbsp; &nbsp; &nbsp;
							<button class="btn" type="reset">
								<i class="icon-undo bigger-110"></i>
								重置
							</button>
						</div>
					</div>
						
				</form>
			</div><!-- /.col -->
		</div><!-- /.row -->
	</div><!-- /.page-content -->
</div><!-- /.main-content -->

{{end}}

{{block after_footer}}
<script type="text/javascript">
    $(document).ready(function(){
        //接收表单验证通过的事件
        $('#dataform').bind('valid.form', function(e, form){
            $.ajax({
                url: '/user/userchangepassword',
                type: 'post',
                data: $(this).serialize(),
                success: function(d){
                    //$('#showmsg').fadeIn(300).delay(2000).fadeOut(500);
                    //$('#showmsg').html(d.msg).show().fadeIn(300).delay(2000).fadeOut(500);
                    if (d.status==200){
                        var msg = d.msg;
                        msg += '<br /><h4>页面将在5秒后跳转...<i class="icon-bell bigger-110 purple"></i>还剩<span id="num">5</span>秒</h4><br />';
                        msgSuccessN(msg);
                        goto(5,'/user/user');
                    }else{
                        msgError(d.msg);
                    }
                }
            });
        });
    });
</script>
{{end}}